<?php

namespace App\Http\Middleware\Auth;
use App\Models\Member;

use App\Http\Services\LoginService;
use Closure;

class MiniappNoLogin
{
    /**
     * 小程序登录验证
     */
    public function handle($request, Closure $next)
    {
        $token = $request->header('token');
        if(!empty($token)){
            $login = new LoginService();
            $adminId = $login->authcode($token,'DECODE');
            // $adminId = 717040 ;
            $request->offsetSet('wechat_admin_id',$adminId);
            define("UID", $adminId ?? "");
        }else{
            define("UID", "");
        }

        return $next($request);
    }
}
